ARG PHP_VERSION=8.4
ARG COMPOSER_VERSION=2.0

FROM composer:${COMPOSER_VERSION}
FROM php:${PHP_VERSION}-fpm

RUN apt-get update && \
    apt-get install -y autoconf pkg-config libssl-dev git libzip-dev zlib1g-dev && \
    pecl install mongodb && docker-php-ext-enable mongodb && \
    pecl install xdebug && docker-php-ext-enable xdebug && \
    docker-php-ext-install -j$(nproc) pdo_mysql zip

COPY --from=composer /usr/bin/composer /usr/local/bin/composer
COPY . /app

RUN composer install --no-interaction --no-scripts --no-suggest --no-plugins --no-progress --optimize-autoloader
RUN php artisan optimize:clear
RUN php artisan config:cache
RUN php artisan config:clear
RUN php artisan view:clear
RUN php artisan cache:clear
RUN php artisan route:clear
RUN php artisan config:cache
RUN php artisan optimize
RUN php artisan view:cache
RUN php artisan key:generate --force
RUN chmod -R 777 /app/storage
RUN chmod -R 777 /app/bootstrap/cache
RUN chmod -R 777 /app/vendor
RUN chmod -R 777 /app/public


EXPOSE 9000
CMD ["php-fpm"]
WORKDIR /app
